import { API_URI } from '../constants/index';


export async function apiCall(
    endpoint: string, token: string, body: object
) {
    const requestHeaders: HeadersInit = new Headers();
    requestHeaders.set('Content-Type', 'application/json');
    requestHeaders.set('Authorization', `Bearer ${token}`);
    const response = await fetch(
        API_URI + endpoint,
        {
            method: 'POST',
            headers: requestHeaders,
            body: JSON.stringify(body),
        }
    );
    return response.json();
}